#ifndef IMAGEVIEWER_H
#define IMAGEVIEWER_H

#include "icons.cxx"


#include <FL/Fl.H>
#include <FL/Fl_Gl_Window.h>
#include <FL/gl.h>
#include <FL/Fl_Double_Window.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Menu_Bar.H>
#include <FL/Fl_Menu_Button.H>
#include <FL/Fl_Text_Display.H>
#include <FL/fl_file_chooser.h>
#include <Fl/Fl_Pixmap.h>
#include <FL/Fl_Scroll.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Slider.H>
#include <FL/Fl_Group.H>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <time.h>

#include <cmath>
#include <math.h>

#include <list>
#include <string>
#include <iterator>
#include <FL/Fl_Image.H>
#include <FL/Fl_JPEG_Image.H>
#include <FL/Fl_Shared_Image.H>
#include <FL/Fl_Box.H>
#include<FL/Fl_PNG_Image.H>


struct Point{
double x; // holds mouse x
double y; // holds mouse y
double z;
};


// should be used when handling colors (like with the color tool) ints
class pixelInt{
public:
	int r; // of course this is an interger holding the red value...
	int g; // " green "
	int b; // " blue "

	pixelInt() {r=0, b=0, g=0;}
};

// should be used when handling colors (like with the color tool) using unsigned chars
struct pixelUC{
	unsigned char r; // of course unsigned char holding the red of the pixel assigned to it
	unsigned char g; // green
	unsigned char b; // blue
};

// an evil data container for an evil project
// this looks like something I might just add to the image class making it even larger... 
// but really is a container for images UGH!
// has nothing to do with them...
struct undoCtr{
	int y;// image hieght
	int x;// image width
	int channels; //image channels (usually rgb 3)
	double rotation;
	unsigned char * imageData; // pointer to the data
};


// Demonstrate how to display a pixel buffer in FLTK

// WINDOW CLASS TO HANDLE DRAWING IMAGE
class MyWindow : public Fl_Double_Window  {
public:
   


	void draw();


	//used for event handling of the mouse
	int handle(int event);

	//gets the mouse possition and passes back
	void getMouse(Point *mouse);

	//outputs the mouse position, and color values
	//void outColorMouse();

	// Constructor
    MyWindow(int w, int h, const char *name=0) : Fl_Double_Window(w,h,name) {
                         
    }

public:
	Point mouseClick; // holds point for when mouse was clicked
	bool selectionRectangle; // will be used for selection box
	Point mousePosition; // point for mouse to be polled

};


class Image
{
public:
      unsigned char *data;
	  int nx;
      int ny;
      int ncolorChannels;
      int n;
	  int size;
	  double rotation;
	  char imageType[3];
	  char str[100];

      Image(){nx=ny=ncolorChannels=n=0;}

	  unsigned char getPixel(int x, int y, int i);
	  void setPixel(int x, int y, int i, int value);
	  void modPixel(int x, int y, int i, int value);
	  void modImage(int r,int g,int b); // updates the image by adding what ever value is passed to it for each channel (this is applied to the whole image!)
	  void copyFromImage(unsigned char *image);// copies image to a data location passed to it, should be the same size... you know...?
	  void copyToImage(unsigned char *image); // Copies to the image the data passed to it, key part is the sizes of shit...
      void ReadFile();
	  void Read_ppm(char *);
	  void Read_jpg(char *);
	  void Read_bmp(char *);
	  void Read_gif(char *);
	  void Read_png(char *);
	  void flush_buffer();
	  void renderImage();
	  void grayscale();
	  void redChannel();
	  void greenChannel();
	  void blueChannel();
	  void mirrorX();
	  void mirrorY();
	  void zoom();
	  void brighten();
	  void darken();
	  void rotate(double);
	  void posterize();
	  void WriteFile();
	  void Write_ppm(char *);
	  void Write_jpg();
	  void Write_bmp();
	  void Write_gif();
	  void Write_png();
	  int get_file_type(std::string);
	  ~Image() {if(n) delete[] data;}
	  Image& operator=(const Image&);
	
};
#endif 